<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<%@ include file="/commons/commonEdit.jsp"%>
<%@ include file="/commons/commonList.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
<script type="text/javascript" src="${ctx}/scripts/common.js"></script>
<script type="text/javascript">

var currentCount=0;


    function submitForm(){
    var selectId=getSelectId();
    if(selectId == '')
	  {
	   Alert('请选择一条记录!');
	   return false;
	  }
	  if('${multiple}'=="false"){
	     if(selectId.indexOf(',')!=-1){
	      Alert('只能选择一条记录!');
	        return false;
	     }
	  }

     document.getElementById("deptIdStr").value=selectId;
      selectId="";
       document.addForm.submit();

     }

     function getSelectId(){
		var tableObj = document.getElementById("ec_table");
		var checkBoxArray = tableObj.getElementsByTagName("input");
		var selectedId = new Array();
		for(var i = 0; i < checkBoxArray.length; i++){
			if(checkBoxArray[i].type != "checkbox") continue;
			if(checkBoxArray[i].checked){
				selectedId[selectedId.length] = checkBoxArray[i].value;
			}
		}
		return selectedId.toString();
	}

	function checkBoxOnClick(ojb){
	  if(ojb.checked){
	  var  chkbxNum= document.getElementsByName('deptId');
	  var chckHeader= true;for (var i=0; i< chkbxNum.length; i++){
	  chckHeader= chckHeader && chkbxNum[i].checked;
	  }

	  if(chckHeader){
	  document.getElementById('deptId_selector').checked = true;
	  }else{
	  document.getElementById('deptId_selector').checked=false;
	  }
	 }
	}

</script>
</head>

<body>


<form  name="addForm" id="addForm" action="${ctx}/common_employeeQuery.do?method=saveSelectDept&frameName=${frameName}&callBack=${callBack}" method="post">

<input type="hidden" name="deptIdStr" value="">

</form>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td class="window_head_outBg"><table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td><img src="${ctx}/images/ico_Advance.gif" width="16" height="16" align="absmiddle"> <span class="window_head_intext">选择部门</span></td>
        </tr>
    </table></td>
  </tr>
  <tr>
    <td class="aux_header_line_1"></td>
  </tr>
  <tr>
    <td class="aux_header_line_2"></td>
  </tr>

  <tr>
    <td class="aux_header_line_2">
		<div style="overflow:auto; height:420px;">
		<ec:ceTable items="deptList"
			action="${ctx}/common_employeeQuery.do?method=getAllDeptList"
			var="deptItem"
			view="pmsNoPageView"
			styleClass="gridData2"
			rowsDisplayed="${totalRows}" >
			<ec:ceRow styleClass="grid"  ondblclick="removePerson('${deptItem.deptId}');">
			<ec:ceColumn headerCell="checkboxHeader"  property="deptId" sortable="false" width="5%" showTitle="false">
			<input type="checkbox"  name="deptId"  value="${deptItem.deptId}"  onclick="checkBoxOnClick(this);" ${deptItem.hadSelect=='1'?'checked':''}/>
			</ec:ceColumn>
				<ec:ceColumn headerCell="pmsHeadrCell" title="部门名称" property="deptName" sortable="true" width="30%" />
				<ec:ceColumn headerCell="pmsHeadrCell" title="部门代码" property="deptNumber" width="30%"/>
				<ec:ceColumn headerCell="pmsHeadrCell" title="备注" property="remark" width="30%"/>
			</ec:ceRow>
		</ec:ceTable>
		</div>
    </td>
  </tr>

  <tr>
    <td class="aux_header_line_1">
			<table width="100%" border="0" cellpadding="0" cellspacing="0">
			<tr>
			    <td class="window_footer"><table border="0" align="right" cellpadding="0" cellspacing="0">
			        <tr>
			          <td><table border="0" cellpadding="0" cellspacing="0">

			          </table></td>
					  <td class="btn_between_space"></td>
			          <td><table border="0" cellpadding="0" cellspacing="0" >
			            <tr>
			              <td class="buttonOffLeft" id="btn1_51"></td>
			              <td class="buttonOffMiddle" id="btn1_52" onblur="btn_change(5)" onMouseOver="btn_change_over(5)" onMouseOut="btn_change_out(5)" onClick="submitForm();"><img src="${ctx}/images/ico_ok.gif" border="0" align="absmiddle" />${key.save}</td>
			              <td class="buttonOffRight" id="btn1_53"></td>
			            </tr>
			        </table></td>
			        <td class="btn_between_space"></td>
			        <td><table border="0" cellpadding="0" cellspacing="0">
			            <tr>
			              <td class="buttonOffLeft" id="btn1_31"></td>
			              <td class="buttonOffMiddle" id="btn1_32" onblur="btn_change(3)"  onClick="windowClose();" onMouseOver="btn_change_over(3)" onMouseOut="btn_change_out(3)"><img src="${ctx}/images/ico_cancel.gif" border="0" align="absmiddle" />${key.close}</td>
			              <td class="buttonOffRight" id="btn1_33"></td>
			            </tr>
			        </table></td>
			      </tr>
			    </table></td>
			  </tr>
			</table>
    </td>
  </tr>

  </table>



</body>
</html>
